﻿<!--#include file="h.asp"--><%
'
'	七色虎建站系统
'	文件下载页面
'	2012.6.2

Sub main
	Dim userid,body_,id,rs,a,buy,owner,buyer,url
	userid=user_array(0)
	checkLogin()'验证登录
	id=getN("id",0)
	a=getData("a")
	hu.title = "文件下载"
	body_ = checkMsg()'信息
	'作者下载免费
	body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-文件下载[/div]"
	If a="" Then
		Set rs=hu.conn("select top 1 buy,userid from 74hu_download where id="&id)
		If Not rs.eof Then
			body_ = body_ & "下载文件需要"&rs("buy")&""&bbsMoney&"，是否下载？<br/>"&_
				hu.url("download.asp?id="&id&"&amp;a=1","提取下载地址")& "<br/>[div=tip]提示:作者免费下载，已下载过的不重复扣费[/div]"
		Else
			body_ = body_ & "文件不存在!"
		End If
	Else
		'防止盗链 
		' From_url = Cstr(Request.ServerVariables("HTTP_REFERER")) 
		' Serv_url = Cstr(Request.ServerVariables("SERVER_NAME")) 
		' if mid(From_url,8,len(Serv_url)) <> Serv_url then 
			' rupt "错误","非法链接！"
		' end if 
		Set rs=hu.conn("select top 1 buy,userid,url,buyer from 74hu_download where id="&id)
		If Not rs.eof Then
			buy=rs("buy")
			buyer=rs("buyer")&""
			owner=rs("userid")
			url=rs("url")
			If buy>0 And owner<>userid And InStr(","&buyer&",",","&userid&",")=0 Then
				Call setUserAmountBySelf(userid, "-"&buy&",0,0")'会员消费金币
				hu.conn("update 74hu_download set buyer='"&buyer&","&userid&"' where id="&id)
			End If
			hu.autoRedirect = url
			body_ = body_ & "正在下载,请稍后...<br/>如果未能下载,请<a href="""&url&""">手动下载</a>！"
		Else
			body_ = body_ & "文件不存在!"
		End If
	End If
	hu.body = comUbb(body_)
End Sub

%>